#ifndef HAIKUOS_INCLUDE_OS_NET_NETBUFFER_H
#define HAIKUOS_INCLUDE_OS_NET_NETBUFFER_H

#include <Archivable.h>
#include <SupportDefs.h>

struct BMessage;
struct DynamicBuffer;

struct BNetBuffer : public BArchivable {
    BNetBuffer(size_t size = 0);
    virtual ~BNetBuffer();

    BNetBuffer(const BNetBuffer& buffer);
    BNetBuffer(BMessage* archive);

    BNetBuffer& operator=(const BNetBuffer& buffer);

    virtual status_t Archive(BMessage* into, bool deep = true) const;
    static BArchiable* Instantiate(BMessage* archive);

    status_t InitCheck();
    // append funcs
    status_t AppendInt8(int8 data);
    status_t AppendUint8(uint8 data);
    status_t AppendInt16(int16 data);
    status_t AppendUint16(uint16 data);
    status_t AppendInt32(int32 data);
    status_t AppendUint32(uint32 data);
    status_t AppendFloat(float data);
    status_t AppendDouble(double data);
    status_t AppendString(const char* data);
    status_t AppendData(const void* data, size_t size);
    status_t AppendMessage(const BMessage& data);
    status_t AppendInt64(int64  data);
    status_t AppendUint64(uint64 data);
    // remove funcs
    status_t RemoveInt8(int8& data);
    status_t RemoveIUint8(uint8& data);
    // TODO:


    inline DynamicBuffer* GetImpl() const;

protected:
    status_t fInit;
private:
    virtual void _ReserveBNetBufferFBCCruft1();
    virtual void _ReserveBNetBufferFBCCruft2();
    virtual void _ReserveBNetBufferFBCCruft3();
    virtual void _ReserveBNetBufferFBCCruft4();
    virtual void _ReserveBNetBufferFBCCruft5();
    virtual void _ReserveBNetBufferFBCCruft6();

    DynamicBuffer* fImpl;
    int32 __ResvervedNetBufferFBCCruftData[8];
};
// impl design pattern 
inline DynamicBuffer*
BNetBuffer::GetImpl() const {
    return fImpl;
}

#endif // header file protect
